const string = "the brown fox jumped over the blue fox";

function Dictionary() {
    this.dataStore = new Array();
    this.add = add;
    this.showAll = showAll;
    this.find = find;

}


function add(key) {
    if(this.find(key)) {
        this.dataStore[key] += 1;
    } else {
        this.dataStore[key] = 1;
    }
}


function find(key) {
    return !!this.dataStore[key];
}


function showAll() {
    for(let key of Object.keys(this.dataStore)) {
        console.log(key + ': ' + this.dataStore[key])
    }
}
const messages = new Dictionary();
const arr = string.split(" ");
for (let item of arr) {
    messages.add(item);
}
messages.showAll();
